package hdb.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import hdb.dao.ArtikelDao;

/** 
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
 * @author juergen.schoenwaelder@stud.fh-deggendorf.de, 
 * 			thomas.eberhart@stud.fh-deggendorf.de
 */
public class StartVorrat extends AbstractController {
	private ArtikelDao artikelDao;

	public void setArtikelDao(ArtikelDao artikelDao) {
		this.artikelDao = artikelDao;
	}
	
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.addObject("title", "Vorrat eingeben");
		mv.addObject("message", "Wählen Sie einen Artikel aus dem Artikelbestand aus:");
		mv.addObject("artikel", artikelDao.findAll());
		mv.addObject("edit", false);
		mv.setViewName("list-artikel");
		return mv;
	}

}
